<template>
  <div>
    <el-row >
      <el-col :span="3"><div class="grid-content bg-purple">
        <el-link :underline="false" class="links" ><img src="../assets/img/dihuang.png" width="140px" height="60px" /></el-link>
      </div></el-col>
      <el-col :span="18"><div class="grid-content bg-purple-light">
        <ul id="ul1" style="width: 100%;min-width: 900px">
          <!--<li><router-link to="/"><el-link :underline="false" class="links" >首页</el-link></router-link></li>
          <li><router-link to="/Course"><el-link :underline="false" class="links">课程中心</el-link></router-link></li>
          <li><router-link to="/SVIP"><el-link :underline="false" class="links">SVIP会员</el-link></router-link></li>
          <li><el-link :underline="false" class="links">订单管理</el-link></li>
          <li><el-link :underline="false" class="links">讲师招募</el-link></li>-->
          <li v-for="title in titles" :key="title.gid">
            <router-link :to="title.gtarget"><el-link :underline="false" class="links" >{{title.gtitle}}</el-link></router-link>
          </li>
        </ul>
      </div></el-col>
      <el-col :span="3">
        <div class="grid-content bg-purple">
          <ul id="ul2" v-if="user == true">
            <li><router-link :to="{path:'/login2'}"><el-link :underline="false" class="links">登陆</el-link></router-link></li>
            <li>/</li>
            <li><router-link :to="{path:'/login2'}"><el-link :underline="false" class="links">注册</el-link></router-link></li>
          </ul>
          <ul id="ul3" v-else>
            <!--<li><el-link href="/#/myOrder" :underline="false" style="font-size: 15px" target="_blank">我的课程</el-link></li>-->

            <li>
              <el-popover
                width="300"
                trigger="hover">
                <div>
                  <el-avatar :src="account.uimage" :size="60" style="float: left"></el-avatar>
                  <p style="padding: 20px;font-size: 20px;margin-left: 50px">{{account.uphone}}<i class="el-icon-star-on"></i></p>
                </div>
                <div id="private">
                  <router-link to="/PersonalCenterBody"><el-link :underline="false" class="asd" target="_blank">个人中心</el-link></router-link>
                </div>
                <el-link @click="quit()" :underline="false" target="_blank" class="asd">退出登录</el-link><br/>
                <el-button id="headBtn" slot="reference">
                  <el-avatar :src="account.uimage"></el-avatar>
                </el-button>
              </el-popover>
            </li>
          </ul>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
    import Bottom from "./Bottom";
    import qs from 'qs'
    export default {
        name: "Navbar",
      components: {Bottom},
      data() {
          return {
            input1: '',
            titles:[],
            user:sessionStorage.getItem('uid')==null,
            account:'',
            userid:{
              uid:sessionStorage.getItem('uid'),
            },
           }
        },
      created(){
        this.getData();
        this.findAll();
      },
      methods:{
        getData(){
          this.$axios2.get("homepage/home-gps/findByStatus").then(r=>{
            //alert(JSON.stringify(r.data))
            this.titles=r.data;

          })
        },
        quit(){
          window.sessionStorage.clear();
          this.$router.push('/login2')
        },
        findAll(){
          this.$axios2.post("/order/orderInfo/findOneUser",qs.stringify(this.userid)).then(res=>{
            this.account = res.data;
            //alert(JSON.stringify(res.data))
          })
        }
      }
    }
</script>

<style scoped>
  a {
    text-decoration: none;
  }
  .grid-content {
    min-height: 60px;
    text-align:center;
  }
  ul{
    margin: 0;
    padding: 0;
  }
  #ul1 li{
    float: left;
    list-style-type: none;
    margin-right:2%;
    margin-top: 1%;
  }
  #ul2 {
    margin-left: 20%;
    width: 150px;
  }
  #ul2 li{
    float: left;
    list-style-type: none;
    margin-left:1%;
    margin-top: 8%;
  }
  #ul3{
    width: 150px;
    line-height: 60px;
    font-size: 20px;
  }
  #ul3 a{
    color: gray;
  }
  #ul3 li{
    float: left;
    list-style-type: none;

  }
  #ul3 a:hover{
    color: red;
  }
  .links {
    font-size: 20px;
  }
  .links:hover {
    color:red;
  }
  #headBtn{
    border-radius: 100px;
    padding: 5px;
    margin-left: 10px;
  }
  .asd{
    float: left;
    padding:0 45px;
  }
</style>

